home *** CD-ROM | disk | FTP | other *** search
- " ----------------------------------------------------------------------"
- " ParallelDevice Class is derived from abstract Device Class. "
-
- " WARNING: You should know what you're doing to the Amiga OS before "
- " messing with this Class, or any other System Class! "
-
- " This class is a Singleton Class. In the future, this class will be "
- " modified to allow more than one Parallel port to be open at a time "
- " (for those of us fortunate enough to have more than one Parallel Port."
- " Methods will have to be added for specifying the parallel device name."
-
- " NOTES
-
- parallelFlags can have any or all of the following values:
-
- 2r00000010 PARF_EOFMODE - check I/O against the TermChars array.
- 2r00000100 PARF_ACKMODE - use ACK handshaking.
- 2r00001000 PARF_FASTMODE - Send out data as long as BUSY is low.
- 2r00010000 PARF_SLOWMODE - For transfers to slow printers.
- 2r00100000 PARF_SHARED - Allow sharing of the parallel device. "
-
- " The parallel.device will NOT open without the PARF_SHARED flag, so "
- " AmigaTalk will ensure that PARF_SHARED is present & supply it if not"
-
- " For the status method, the returned status has the following meaning:"
-
- " BIT: ACTIVE: FUNCTION:"
-
- " 0 HIGH Printer Busy toggle (offline)."
- " 1 HIGH Paper out."
- " 2 HIGH Printer Select."
- " 3 ---- Read = 0, Write = 1"
- " 4-7 ---- Reserved."
-
- " ----------------------------------------------------------------------"
-
- Class ParallelDevice :Device ! uniqueInstance !
- [
- status
- ^ <primitive 224 3>
- |
- resetPort
- ^ <primitive 224 4>
- |
- flushPort
- ^ <primitive 224 5>
- |
- stopPort
- ^ <primitive 224 6>
- |
- startPort
- ^ <primitive 224 7>
- |
- setTerminatorsTo: aString
- "Only the first 4 characters of the string are used."
- "They have to be in descending ASCII sequence."
- ^ <primitive 224 11 aString>
- |
- setPortDirectionAtomic: rwFlag
- " Not needed for reading & writing to the Parallel Port."
- ^ <primitive 224 12 rwFlag>
- |
- sendPortControlBits: newBits
- " Only the 3 least-significant bits will be written to the hardware.
- This is to prevent your code from interfering with the Serial
- device.
- "
- ^ <primitive 224 13 newBits>
- |
- readControlBitsMaskedBy: ctrlMask
- " Only the 3 least-significant bits have any meaning
- for the Parallel Port. Use ctrlMask of seven (7).
- "
- ^ <primitive 224 14 ctrlMask>
- |
- testToggleCtrlBits: loopCount
- "Use this method only for verifying operation of control bits"
- "using test equipment of some kind on your hardware!"
- "loopCount of 1 is around 60 milli-Seconds so do NOT use values"
- "greater than 60,000 (over 1 hour)"
- <primitive 224 15 loopCount>
- |
- testToggleDataBits: loopCount
- "Use this method only for verifying operation of data bits"
- "using test equipment of some kind on your hardware!"
- "loopCount of 1 is around 60 milli-Seconds so do NOT use values"
- "greater than 60,000 (over 1 hour)"
- <primitive 224 16 loopCount>
- |
- privateOpen: parallelFlags ! check !
-
- "open: devName unit: unitNum withFlags: parallelFlags -- for later."
-
- check <- <primitive 224 1 parallelFlags>.
-
- (check ~= 0)
- ifTrue: [ 'Error opening parallel.device:' print.
- <primitive 224 2 check> print.
- ^ nil
- ].
- ^ self
- |
- close
- <primitive 224 0>
- |
- new
- 'Cannot use new method on Parallel class!' print.
- ^ nil
- |
- privateSetup: parallelFlags ! chk !
- (uniqueInstance isNil)
- ifTrue: [ chk <- (self privateOpen: parallelFlags).
-
- (chk ~= nil)
- ifTrue: [uniqueInstance <- self] "<- chk??"
- ].
-
- (chk ~= nil)
- ifTrue: [^ self] "^ uniqueInstance??"
- ifFalse: [^ nil ]
- |
- new: parallelFlags
- ^ (self privateSetup: parallelFlags)
- |
- readThisMany: numChars
- ^ <primitive 224 9 numChars>
- |
- writeToPort: aString thisLong: numChars ! check !
- "your device must handshake with the Amiga. Most printers do."
- check <- <primitive 224 10 numChars aString>.
-
- (check ~= numChars)
- ifTrue: [ 'Parallel Port write error!' print]
- ]
-